<!-- src/views/front/Home.vue -->
<template>
  <div class="home">
    <!-- 全屏视频背景部分 -->
    <section class="hero-section" ref="heroSection">
      <video class="background-video" autoplay loop muted playsinline>
        <source src="@/assets/videos/home.mp4" type="video/mp4">
      </video>
      <div class="hero-content">
        <h1 class="hero-title">发现精彩视界</h1>
        <p class="hero-subtitle">海量视频内容，总有你想看的</p>
        <a href="/videos" class="explore-btn">开始探索</a>
      </div>
      <div class="scroll-indicator" @click="scrollToFeatured">
        <span class="scroll-text">向下滚动</span>
        <i class="el-icon-arrow-down"></i>
      </div>
    </section>

    <!-- 精选内容部分 -->
    <section class="featured-section" ref="featuredSection">
      <div class="section-header">
        <h2>精选内容</h2>
        <div class="category-tabs">
          <el-tabs v-model="activeCategory" @tab-click="handleCategoryChange">
            <el-tab-pane 
              v-for="category in categories" 
              :key="category.id" 
              :label="category.name"
              :name="category.id"
            >
              <div class="video-grid">
                <VideoCard
                  v-for="video in category.videos"
                  :key="video.id"
                  :video="video"
                  class="video-card"
                />
              </div>
            </el-tab-pane>
          </el-tabs>
        </div>
      </div>
    </section>

    <!-- 热门分类部分 -->
    <section class="categories-section">
      <div class="section-header">
        <h2>热门分类</h2>
        <div class="categories-grid">
          <div 
            v-for="category in popularCategories" 
            :key="category.id"
            class="category-item"
            @click="navigateToCategory(category.id)"
          >
            <div class="category-icon">
              <i :class="category.icon"></i>
              </div>
            <div class="category-info">
              <h3>{{ category.name }}</h3>
              <p>{{ category.count }}个视频</p>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 最新上线部分 -->
    <section class="latest-section">
      <div class="section-header">
        <h2>最新上线</h2>
        <div class="latest-list">
          <div 
            v-for="video in latestVideos" 
            :key="video.id"
            class="latest-item"
            @click="navigateToVideo(video.id)"
          >
            <div class="latest-thumbnail">
              <img :src="video.thumbnail" :alt="video.title">
              <span class="duration">{{ video.duration }}</span>
              </div>
            <div class="latest-info">
              <h3>{{ video.title }}</h3>
              <p class="description">{{ video.description }}</p>
              <div class="meta">
                <span class="category">{{ video.category }}</span>
                <span class="views">{{ video.views }}次观看</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 数据统计部分 -->
    <section class="stats-section">
      <div class="stats-container">
        <div class="stat-item">
          <i class="el-icon-video-camera"></i>
          <div class="stat-content">
            <h3>{{ stats.totalVideos }}</h3>
            <p>视频总数</p>
          </div>
            </div>
        <div class="stat-item">
          <i class="el-icon-user"></i>
          <div class="stat-content">
            <h3>{{ stats.totalUsers }}</h3>
            <p>注册用户</p>
          </div>
            </div>
        <div class="stat-item">
          <i class="el-icon-view"></i>
          <div class="stat-content">
            <h3>{{ stats.totalViews }}</h3>
            <p>总播放量</p>
          </div>
            </div>
        <div class="stat-item">
          <i class="el-icon-time"></i>
          <div class="stat-content">
            <h3>{{ stats.dailyUpdates }}</h3>
            <p>每日更新</p>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script>
import VideoCard from '@/components/common/VideoCard.vue'

export default {
  name: 'Home',
  components: {
    VideoCard
  },
  data() {
    return {
      searchQuery: '',
      activeCategory: '1',
      isScrolling: false,
      searchSuggestions: [
        '热门电影',
        '最新电视剧',
        '动漫新番',
        '综艺节目'
      ],
      popularCategories: [
  {
    id: 1,
          name: '动作电影',
          count: 328,
          icon: 'el-icon-video-camera'
  },
  {
    id: 2,
          name: '爱情剧',
          count: 256,
          icon: 'el-icon-star-on'
  },
  {
    id: 3,
          name: '动漫',
          count: 412,
          icon: 'el-icon-picture'
        },
        {
          id: 4,
          name: '纪录片',
          count: 189,
          icon: 'el-icon-camera'
        }
      ],
      latestVideos: [
        {
          id: 3,
          title: '最新上线视频1',
          thumbnail: '/path/to/thumbnail3.jpg',
          duration: '1:30',
          category: '电影',
          views: 500,
          description: '这是最新上线的视频描述...'
        },
        // ... 更多最新视频
      ],
      stats: {
        totalVideos: '10,000+',
        totalUsers: '500,000+',
        totalViews: '1亿+',
        dailyUpdates: '100+'
      },
      categories: [
        {
          id: '1',
          name: '热门推荐',
          videos: [
  {
    id: 1,
              title: '示例视频1',
              thumbnail: '/path/to/thumbnail1.jpg',
              duration: '2:30',
              category: '电影',
              views: 1000,
              description: '这是一个示例视频描述...'
            },
            // ... 更多视频
          ]
        },
        {
          id: '2',
          name: '最新上线',
          videos: [
  {
    id: 2,
              title: '示例视频2',
              thumbnail: '/path/to/thumbnail2.jpg',
              duration: '1:45',
              category: '电视剧',
              views: 800,
              description: '这是另一个示例视频描述...'
            },
            // ... 更多视频
          ]
        },
        // ... 更多分类
      ]
    }
  },
  methods: {
    handleSearch() {
      if (this.searchQuery.trim()) {
        this.$router.push(`/search?q=${encodeURIComponent(this.searchQuery)}`)
      }
    },
    handleCategoryChange(tab) {
      // 处理分类切换
    },
    scrollToFeatured() {
      if (this.isScrolling) return
      this.isScrolling = true
      
      const featuredSection = this.$refs.featuredSection
      if (featuredSection) {
        featuredSection.scrollIntoView({ 
          behavior: 'smooth',
          block: 'start'
        })
        
        // 添加动画效果
        setTimeout(() => {
          featuredSection.style.opacity = '1'
          featuredSection.style.transform = 'translateY(0)'
        }, 100)
      }
      
      setTimeout(() => {
        this.isScrolling = false
      }, 1000)
    },
    handleWheel(event) {
      const heroSection = this.$refs.heroSection
      if (heroSection && event.deltaY > 0 && !this.isScrolling) {
        const heroRect = heroSection.getBoundingClientRect()
        // 只要在 hero section 区域内滚动就触发
        if (heroRect.top <= 0 && heroRect.bottom >= 0) {
          event.preventDefault()
          this.scrollToFeatured()
        }
      }
    },
    navigateToCategory(id) {
      this.$router.push(`/category/${id}`)
    },
    navigateToVideo(id) {
      this.$router.push(`/video/${id}`)
    }
  },
  mounted() {
    window.addEventListener('wheel', this.handleWheel, { passive: false })
  },
  beforeDestroy() {
    window.removeEventListener('wheel', this.handleWheel)
  }
}
</script>

<style scoped>
.home {
  min-height: 100vh;
}

.hero-section {
  height: 100vh;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.background-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.7),
    rgba(0, 0, 0, 0.9)
  );
  z-index: -1;
}

.hero-content {
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-title {
  font-size: 5.5rem;
  font-weight: 900;
  color: #ffffff;
  margin-bottom: 1.5rem;
  line-height: 1.2;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  background: rgba(0, 0, 0, 0.4);
  padding: 0.8rem 2.5rem;
  border-radius: 15px;
  display: inline-block;
  animation: titleSlideIn 1s ease-out;
  position: relative;
  overflow: hidden;
  letter-spacing: 2px;
}

.hero-title::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.2),
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: rotate(45deg);
  animation: shimmer 3s infinite;
}

.hero-title::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  animation: shimmerX 2s infinite;
}

.hero-subtitle {
  font-size: 2.5rem;
  font-weight: 500;
  color: #e0f7fa;
  margin-bottom: 2rem;
  line-height: 1.4;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  background: rgba(0, 0, 0, 0.3);
  padding: 0.8rem 2.5rem;
  border-radius: 15px;
  display: inline-block;
  animation: subtitleFadeIn 1s ease-out 0.3s both;
  position: relative;
  overflow: hidden;
  letter-spacing: 1px;
}

.hero-subtitle::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.2),
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: rotate(45deg);
  animation: shimmer 3s infinite;
  animation-delay: 1s;
}

.hero-subtitle::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  animation: shimmerX 2s infinite;
  animation-delay: 1s;
}

.explore-btn {
  display: inline-block;
  padding: 1rem 3rem;
  font-size: 1.6rem;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 2rem;
  position: relative;
  cursor: pointer;
  animation: explorePulse 2s infinite;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border-radius: 40px;
  color: #b2ebf2;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  overflow: hidden;
  letter-spacing: 2px;
}

.explore-btn::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.2),
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: rotate(45deg);
  animation: shimmer 3s infinite;
}

.explore-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

@keyframes titleSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes subtitleFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes explorePulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%) rotate(45deg);
  }
  100% {
    transform: translateX(100%) rotate(45deg);
  }
}

@keyframes shimmerX {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.search-box {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  margin-top: 1rem;
}

.search-wrapper {
  position: relative;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  gap: 1rem;
}

.search-input-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 30px;
  padding: 0 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.search-input-container:focus-within {
  box-shadow: 0 4px 25px rgba(0, 123, 255, 0.3);
  transform: translateY(-2px);
}

.search-icon {
  font-size: 1.5rem;
  color: #666;
  margin-right: 10px;
}

.custom-search-input {
  flex: 1;
  height: 60px;
  border: none;
  background: transparent;
  font-size: 1.2rem;
  color: #333;
  outline: none;
}

.custom-search-input::placeholder {
  color: #999;
}

.clear-icon {
  font-size: 1.2rem;
  color: #666;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.clear-icon:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

.search-button {
  height: 60px;
  padding: 0 40px;
  font-size: 1.2rem;
  border-radius: 30px;
  background: linear-gradient(45deg, #007bff, #00bcd4);
  border: none;
  box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
  transition: all 0.3s ease;
}

.search-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  margin-top: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  z-index: 1000;
}

.suggestion-item {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.suggestion-item:hover {
  background-color: rgba(0, 123, 255, 0.1);
}

.suggestion-item i {
  color: #007bff;
}

.scroll-text {
  font-size: 1.4rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  animation: scrollTextGlow 2s infinite;
}

@keyframes scrollTextGlow {
  0%, 100% {
    opacity: 1;
    transform: translateY(0);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  }
  50% {
    opacity: 0.8;
    transform: translateY(-5px);
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
  }
}

.scroll-indicator {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.scroll-indicator i {
  font-size: 1.8rem;
  animation: scrollArrow 2s infinite;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

@keyframes scrollArrow {
  0%, 100% {
    transform: translateY(0);
    opacity: 1;
  }
  50% {
    transform: translateY(-10px);
    opacity: 0.8;
  }
}

.featured-section {
  padding: 4rem 2rem;
  background: #f8f9fa;
  opacity: 0;
  transform: translateY(50px);
  transition: all 0.8s ease;
  scroll-margin-top: 80px; /* 为固定导航栏留出空间 */
}

.section-header {
  max-width: 1400px;
  margin: 0 auto;
}

.section-header h2 {
  font-size: 2rem;
  margin-bottom: 2rem;
  color: #1a1a1a;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  padding: 1rem 0;
}

.categories-section,
.latest-section,
.stats-section {
  padding: 4rem 2rem;
  background: #fff;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  background: white;
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: all 0.3s ease;
}

.category-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.category-icon {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(45deg, #007bff, #00bcd4);
  border-radius: 15px;
}

.category-icon i {
  font-size: 2rem;
  color: white;
}

.category-info h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: #333;
}

.category-info p {
  color: #666;
  font-size: 0.9rem;
}

.latest-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.latest-item {
  display: flex;
  gap: 1.5rem;
  padding: 1rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: all 0.3s ease;
}

.latest-item:hover {
  transform: translateX(5px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.latest-thumbnail {
  position: relative;
  width: 200px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
}

.latest-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.latest-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.latest-info h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: #333;
}

.latest-info .description {
  color: #666;
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.latest-info .meta {
  display: flex;
  gap: 1rem;
  color: #999;
  font-size: 0.9rem;
}

.stats-section {
  background: linear-gradient(45deg, #1a1a1a, #2c3e50);
  color: white;
}

.stats-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-item i {
  font-size: 2.5rem;
  color: #007bff;
}

.stat-content h3 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.stat-content p {
  color: rgba(255, 255, 255, 0.8);
}

@media (max-width: 768px) {
  .hero-title {
    font-size: 3.5rem;
    padding: 0.6rem 1.8rem;
  }

  .hero-subtitle {
    font-size: 1.8rem;
    padding: 0.6rem 1.8rem;
  }

  .explore-btn {
    font-size: 1.4rem;
    padding: 0.8rem 2rem;
  }

  .latest-item {
    flex-direction: column;
  }

  .latest-thumbnail {
    width: 100%;
    height: 200px;
  }

  .stats-container {
    grid-template-columns: repeat(2, 1fr);
  }
}
</style> 